if not ( RES_DISTRIB == 2 ) then Error("Please Install Resource Distribution 2 Addon.'" ) return end

TOOL.Category = '(Food Mod)'
TOOL.Name = '#Beer Extras(Beta)'
TOOL.Command = nil
TOOL.ConfigName = ''
if (CLIENT and GetConVarNumber("RD_UseLSTab") == 1) then TOOL.Tab = "Life Support" end

TOOL.ClientConVar['type'] = 'beer_processor'
TOOL.ClientConVar['model'] = 'models/props_lab/reciever_cart.mdl'

cleanup.Register('beerextras')

if ( CLIENT ) then
	language.Add( 'Tool_beerextras_name', 'Beer Extras' )
	language.Add( 'Tool_beerextras_desc', 'Create Extra attached to any surface.' )
	language.Add( 'Tool_beerextras_0', 'Left-Click: Spawn a Device.  Right-Click: Repair Device.' )

	language.Add( 'Undone_beerextras', 'Extra Undone' )
	language.Add( 'Cleanup_beerextras', 'Beer Extras' )
	language.Add( 'Cleaned_beerextras', 'Cleaned up all Beer Extras' )
	language.Add( 'SBoxLimit_foodmod', 'Maximum Foodmod Reached. Too Bad.' )
end

local beerextras = {}
if (SERVER) then
	beerextras.beer_processor = function( ply, ent, system_type, system_class, model )
		local rtable = {}
		local maxhealth = 250
		local mass = 5500
		if (model == "models/props_lab/reciever_cart.mdl") then
      maxhealth = 250
      mass = 2000
      rtable.scale = 1
      rtable.efficiency = 1
    else
      maxhealth = 1
      rtable.scale = 0.1
      rtable.efficiency = 0.1
    end
		RD_AddResource(ent, "beers", 0)
		RD_AddResource(ent, "beer", 0)
		RD_AddResource(ent, "energy", 0)
		LS_RegisterEnt(ent, "Generator")
    rtable.mass = mass
		return rtable, maxhealth, mass
	end

	beerextras.beer_bottler = function( ply, ent, system_type, system_class, model )
		local rtable = {}
		local maxhealth = 250
		local mass = 5500
		if (model == "models/props_junk/PlasticCrate01a.mdl") then
      maxhealth = 50
      mass = 100
      RD_AddResource(ent, "beers", 10)
    else
      maxhealth = 1
      RD_AddResource(ent, "beers", 0)
    end
    rtable.mass = mass
		return rtable, maxhealth, mass
	end
end

local beerextras_models = {
	{ 'Beer Bottler', 'models/props_junk/PlasticCrate01a.mdl', 'beer_bottler' },
	{ 'Beer Processor', 'models/props_lab/reciever_cart.mdl', 'beer_processor' },
}

RD2_ToolRegister( TOOL, beerextras_models, nil, "beerextras", 30, beerextras )
